import {
  avaratorRequestApi,
  LoginNewRequestApi,
  LoginRequestApi,
  uploadFileApi,
  userInfoRequestApi,
} from './request';

//获取应用级保护的access_token
export const getAccessTokenApi = (data: any) =>
  LoginRequestApi('/oauth/token', data, 'POST');

//判断账号是否可用(是否注册)
export const identifierAvailableApi = (data: any) =>
  LoginNewRequestApi(
    `/v2/users/identifier-available?identifier=${data.identifier}`,
    '',
    'GET'
  );

// 获取验证码
export const sendCodeApi = (data: any) =>
  LoginNewRequestApi('/v2/sms-verification-code/send', data, 'POST');

// 手机短信验证码登录
export const oauthTokenApi = (data: any) =>
  LoginRequestApi('/oauth/token', data, 'POST');

//基本信息查询
export const userInfoApi = (data: any) =>
  userInfoRequestApi(
    `/v2/haier/userinfo?access_token=${data.access_token}`,
    {},
    'GET'
  );

//更新用户全量信息
export const updateUserInfoApi = (data: any) =>
  userInfoRequestApi('/v2/haier/md/userinfo', data, 'POST');

//用户中心头像上传接口
export const avatarUploadApi = (data: any) =>
  avaratorRequestApi('/v2/user/avatar/upload', data, 'PUT');
//更新基本信息
export const updateBasicInfoApi = (data: any) =>
  userInfoRequestApi('/haier/v1/users/me', data, 'PATCH');
//退出登录
export const signoutApi = (data: any) =>
  userInfoRequestApi('/v2/haier/signout', data, 'POST');
